package com.sword.controller;

import com.sword.common.bean.Result;
import com.sword.invoice.InvoiceManager;
import com.sword.invoice.bean.bo.sales.InvoiceOrder;
import com.sword.invoice.bean.enums.InvoiceChannelEnum;
import com.sword.invoice.repository.AbsBlueInvoiceStrategy;
import com.sword.invoice.spring.SpringContextUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @description: 控制类
 * @author：Lv.RJ
 * @version: 1.0.0
 * @create: 2025/02/17
 **/
@RestController
@RequestMapping("/sword")
public class SwordController {
    // 测试登录  ---- http://localhost:8081/sword/blueinvoice/lq

//    @RequestMapping("blueinvoice/lq")
//    public Result blueinvoice(String type) {
    @RequestMapping(value = "blueinvoice/lq", method = RequestMethod.POST, consumes = "application/json")
    public Result blueinvoice(@RequestBody Map<String, String> params) {
        String type = params.get("type");
//        AbsBlueInvoiceStrategy strategy = InvoiceManager.getISInvoiceDriverRepository(InvoiceChannelEnum.LQ_INVOICE, AbsBlueInvoiceStrategy.class);
        AbsBlueInvoiceStrategy strategy = SpringContextUtil.create(InvoiceChannelEnum.LQ_INVOICE.getCode(), AbsBlueInvoiceStrategy.class);
        InvoiceOrder invoiceOrder = new InvoiceOrder();
        invoiceOrder.setBillInfoNo(type);
        strategy.setOrder(invoiceOrder);

        Result result = strategy.doInvoiceHandler();

        return result;
    }

}
